#include<bits/stdc++.h>
#define fre(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define LL long long
#define db double
using namespace std;
struct list{
	int lst,nxt,to,now;
}a[200005];
int find(int x){
	if(x==a[x].to)return x;
	return a[x].to=find(a[x].to);
}
int main(){
	fre(fruit); 
	int n;
	scanf("%d",&n);a[n+1].now=-1;
	a[0].nxt=1;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i].now),a[i].lst=i-1,a[i].nxt=i+1;
	for(int i=n;i;i--)
	{
		if(a[i].now==a[i+1].now)
		a[i].to=find(i+1);
		else a[i].to=i;
	}
	while(a[0].nxt!=n+1){
		int i=0;
		while(a[i].nxt!=n+1){
			i=a[i].nxt;
			a[a[i].lst].nxt=a[i].nxt;
			a[a[i].nxt].lst=a[i].lst;
			printf("%d ",i);
			i=find(i);
		}
		i=0;
		while(a[i].nxt!=n+1){
			i=a[i].nxt;
			i=find(i);
			if(a[i].now==a[a[i].nxt].now)
			a[i].to=find(a[i].nxt);
		}
		puts("");
	}
	return 0;
}

